Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#4708] improvement(client-java/server): Add implementations for the getFileLocation interface in Java Client / Server #4858

Merged
merged 14 commits into from
Sep 6, 2024

Conversation

xloya
Copy link
Contributor

@xloya xloya commented Sep 5, 2024

What changes were proposed in this pull request?

Add the implementations for getFileLocation interfaces in Java Client / Server.

Why are the changes needed?

Fix: #4708

How was this patch tested?

Add some UTs and ITs.

@xloya xloya force-pushed the add-impl-for-get-file-location branch 2 times, most recently from 342fe36 to 839c2ed Compare September 5, 2024 04:50
@xloya xloya self-assigned this Sep 5, 2024
@xloya xloya force-pushed the add-impl-for-get-file-location branch 2 times, most recently from 18427c1 to 664ac5a Compare September 5, 2024 07:03
@xloya xloya closed this Sep 5, 2024
@xloya xloya reopened this Sep 5, 2024
@xloya xloya force-pushed the add-impl-for-get-file-location branch 2 times, most recently from c9e386c to 3fe438f Compare September 5, 2024 07:25
@xloya xloya closed this Sep 5, 2024
@xloya xloya reopened this Sep 5, 2024
@xloya xloya marked this pull request as ready for review September 5, 2024 08:45
@xloya
Copy link
Contributor Author

xloya commented Sep 5, 2024

@jerryshao Hi, this PR is ready for review, please take a look when you have time, thanks.

@xloya xloya changed the title [#4708] improvement(client-java/server): Add implementations for getFileLocation interfaces in Java Client / Server [#4708] improvement(client-java/server): Add implementations for the getFileLocation interface in Java Client / Server Sep 5, 2024
@xloya xloya force-pushed the add-impl-for-get-file-location branch from 3fe438f to f3227ad Compare September 5, 2024 09:21

CallerContext callerContext = CallerContext.CallerContextHolder.get();
Map<String, String> queryParams = Maps.newHashMap();
queryParams.put("subPath", subPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think maybe we should encoding the subPath to avoid supported chars in the URL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

queryParams.put("subPath", subPath);
FileLocationResponse resp =
restClient.get(
formatFilesetRequestPath(fullNamespace) + "/" + ident.name() + "/" + "fileLocation",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to add the th subPath into the URL, not a queryParam?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I prefer to use the queryParams for the following reasons:

  1. Currently other similar GET APIs pass parameters in the form of queryParams, like RelationalTable.listPartitions();
  2. I looked at the APIs of other commercial products, such as the REST API of Databricks' DBFS, and they also pass these parameters through queryParams: https://docs.databricks.com/api/workspace/dbfs/read;
  3. In the unit test, I tried to directly splice the URL, but it seems that the test framework cannot mock the request, so I guess some frameworks may not recognize the method of directly splicing parameters to the URL.

throw new UnsupportedOperationException("Not implemented");
// The constraints of the name spec may be more strict than underlying catalog,
// and for compatibility reasons, we only apply case-sensitive capabilities here.
return dispatcher.getFileLocation(normalizeCaseSensitive(ident), subPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest split the core part logic into another PR. In this PR, we only focus on client and server side API. Don't make the PR too big, which is hard to review.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, this PR has been split to only include changes with the Java Client and Server.

@xloya xloya force-pushed the add-impl-for-get-file-location branch from 659f7af to 5edebdc Compare September 6, 2024 03:29
CallerContext callerContext = CallerContext.CallerContextHolder.get();

Map<String, String> params = new HashMap<>();
params.put("subPath", RESTUtils.encodeString(subPath));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest we don't use camel style for param here "subPath" and path "fileLocation", how about "sub_path" and "location"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@xloya xloya force-pushed the add-impl-for-get-file-location branch from ac84d2e to 3b36e37 Compare September 6, 2024 06:04
@jerryshao jerryshao merged commit 3731e53 into apache:main Sep 6, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Subtask] Add the implementations for getFileLocation interface in Java Client / Server
2 participants